﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //Test1();
            //Test2();
            //Test3();
            //Test4();
            Test5();
            //Test6();
        }


        static void Test1()
        {
            Console.WriteLine("请输入一个字符串：");
            string str = Console.ReadLine();

            int letterCount = 0;
            int numCount = 0;
            int whitespaceCount = 0;
            foreach (var a in str)
            {
                if (char.IsLetter(a))
                {
                    letterCount++;
                }
                else if (char.IsDigit(a))
                {
                    numCount++;
                }
                else if (char.IsWhiteSpace(a))
                {
                    whitespaceCount++;
                }
            }
            Console.WriteLine("您输入的字符串中，字母有{0}个，数字有{1}个，空格有{2}个", letterCount, numCount, whitespaceCount);
        }

        static void Test2()
        {
            Console.WriteLine("请输入正方形边长：");
            int str = int.Parse(Console.ReadLine());

            for (int i = 1; i <= str; i++)
            {
                for (int j = 1; j <= str; j++)
                {
                    if (i == 1 || i == str || j == 1 || j == str)
                        Console.Write("* ");
                    else
                    {
                        Console.Write("  ");
                    }
                }
                Console.WriteLine();
            }
        }
        //计算总成绩和平均数
        static void Test3()
        {
            double[] points = new double[5];
            for (int i = 0; i < points.Length; i++)
            {
                points[i]= double.Parse(Console.ReadLine());
            }
            
            double sum = 0;
            double avg = 0;
            foreach (double point in points)
            {
                sum = sum + point;
            }
            avg = sum / points.Length;
            Console.WriteLine("总成绩为："+sum);
            Console.WriteLine("平均成绩为："+avg);
        }
        //九九乘法表
        static void Test4() 
        {
            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= i; j++)
                {
                    Console.Write("{0}*{1}={2}\t",i,j,i*j);
                }
                Console.WriteLine();
            }
        }

        //排序
        static void Test5() 
        {
            int[] nums = { 10, 20, 30, 40, 50, 60, 70, 80 };
            for (int i = 0; i < nums.Length-1; i++)
            {
                for (int j = 0; j < nums.Length-1-i; j++)
                {
                    if (nums[j]<nums[j+1])
                    {
                        int temp = nums[j];
                        nums[j] = nums[j + 1];
                        nums[j + 1] = temp;
                    }
                }
            }
            for (int i = 0; i <nums.Length; i++)
            {
                Console.WriteLine(nums[i]);
            }
        }
        static void Test6() 
        {
            Console.WriteLine("请输入要查找的数字：");
            int a = int.Parse(Console.ReadLine());
            int p = -2;
            int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
            
        }
    }
}